package es.pawer.web.checklists.struts2.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;


/**
 * Checks if current user is logged
 * @author plozano
 *
 */
public class LoggedInterceptor implements Interceptor {

	private static final long serialVersionUID = 464811337338670673L;

	@Override
	public void destroy() {
		// Nothing to do
	}

	@Override
	public void init() {
		// Nothing to do
	}

	@Override
	public String intercept(ActionInvocation act) throws Exception {

		if (act.getInvocationContext().getSession().containsKey("user")) {
			return act.invoke();
		} else {
			return "login";
		}
	}

}
